Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins #161

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Plugins #161

wants to merge 8 commits into from

Conversation

stormdragon2976
Copy link

This is a way for people to write and use plugins. Plugins are sourced into the program itself, so everything is available to them. the call to call_plugins could probably be added in a few more places, but this is a good starting point.

Plugins can be added in a subdirectory called plugins, or system wide in /usr/share/bashblog/plugins. I can write more information for the readme, but basically each of them can be in a file, and they are each written as a series of functions. For example, this plugin will show what you were listening to as you wrote the current post:

    [[ -z "$1" ]] && return
    sed -i '/Tags: keep-this-tag-format, tags-are-optional, beware-with-underscores-in-markdown, example/d' "$1"
    echo -n "### Composed to the sound of " >> "$1"
    playerctl metadata -f '{{artist}} - {{album}} - {{title}}' >> "$1"
    echo -e "\nTags: keep-this-tag-format, tags-are-optional, beware-with-underscores-in-markdown, example" >> "$1"
}

So, each plugin must start with the keyword plugin_ followed by where it's called, in this case pre_edit, and then should have a unique identifier, _composed. I think this will add a whole lot more flexibility to an already powerful system, and the lines of code it took to do it were minimal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant